
--USE master
--GO

USE EBAS
GO


if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[EBAS_VERSION]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
	CREATE TABLE [dbo].[EBAS_VERSION] (
		[GUID] [uniqueidentifier] ROWGUIDCOL NOT NULL ,
		[APPLIKATION_DATO] [datetime] NOT NULL ,
		[APPLIKATION_VERSION] [int] IDENTITY (1, 1) NOT NULL ,
		[APPLIKATION_BUILD] [int] NULL ,
		[APPLIKATION_COMMENT] [varchar] (255) COLLATE Danish_Norwegian_CI_AS NULL 
	) ON [PRIMARY]

	ALTER TABLE [dbo].[EBAS_VERSION] WITH NOCHECK ADD 
		CONSTRAINT [DF_EBAS_VERSION_APPLIKATION_DATO] DEFAULT (getdate()) FOR [APPLIKATION_DATO],
		CONSTRAINT [DF_EBAS_VERSION_GUID] DEFAULT (newid()) FOR [GUID],
		CONSTRAINT [PK_EBAS_VERSION] PRIMARY KEY  CLUSTERED 
		(
			[GUID]
		)  ON [PRIMARY] 
END		

DELETE FROM EBAS_VERSION
INSERT INTO EBAS_VERSION (APPLIKATION_COMMENT) VALUES ('Initial version')
INSERT INTO EBAS_VERSION (APPLIKATION_COMMENT) VALUES ('Added basic data')
INSERT INTO EBAS_VERSION (APPLIKATION_COMMENT) VALUES ('Extended security model')
INSERT INTO EBAS_VERSION (APPLIKATION_COMMENT) VALUES ('Changed hash handling and authentification')
GO

USE EBAS
GO
